package com.ruoyi.web.controller.edh;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.edh.domain.EdhCardCase;
import com.ruoyi.edh.service.IEdhCardCaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 易订货-卡包Controller
 *
 * @author xxx
 * @date 2020-09-07
 */
@RestController
@RequestMapping("/edh/case")
@Api(description = "易订货-卡包")
public class EdhCardCaseController extends BaseController {
    @Autowired
    private IEdhCardCaseService edhCardCaseService;

    /**
     * 我的卡包
     */
    @GetMapping("/list")
    @ApiOperation("我的卡包")
    public TableDataInfo list(EdhCardCase edhCardCase) {
        startPage();
        List<EdhCardCase> list = edhCardCaseService.selectEdhCardCaseList(edhCardCase);
        return getDataTable(list);
    }

    /**
     * 导出易订货-卡包列表
     */
    @Log(title = "易订货-卡包", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出易订货-卡包列表")
    public AjaxResult export(EdhCardCase edhCardCase) {
        List<EdhCardCase> list = edhCardCaseService.selectEdhCardCaseList(edhCardCase);
        ExcelUtil<EdhCardCase> util = new ExcelUtil<EdhCardCase>(EdhCardCase.class);
        return util.exportExcel(list, "case");
    }

    /**
     * 获取易订货-卡包详细信息
     */
    @GetMapping
    @ApiOperation("获取易订货-卡包详细信息")
    public AjaxResult getInfo(Long id) {
        return AjaxResult.success(edhCardCaseService.selectEdhCardCaseById(id));
    }

    /**
     * 新增易订货-卡包
     */
    @Log(title = "易订货-卡包", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增易订货-卡包")
    public AjaxResult add(@RequestBody EdhCardCase edhCardCase) {
        return toAjax(edhCardCaseService.insertEdhCardCase(edhCardCase));
    }

    /**
     * 修改易订货-卡包
     */
    @Log(title = "易订货-卡包", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改易订货-卡包")
    public AjaxResult edit(@RequestBody EdhCardCase edhCardCase) {
        return toAjax(edhCardCaseService.updateEdhCardCase(edhCardCase));
    }

    /**
     * 删除易订货-卡包
     */
    @Log(title = "易订货-卡包", businessType = BusinessType.DELETE)
    @GetMapping("/detele")
    @ApiOperation("删除易订货-卡包")
    public AjaxResult remove(Long id) {
        return toAjax(edhCardCaseService.deleteEdhCardCaseById(id));
    }
}
